package com.hospital.serviceImpl;

import com.hospital.dao.FollowUpGroupMapper;
import com.hospital.entity.FollowUpGroup;
import com.hospital.entity.Level;
import com.hospital.entity.ResponsibleDepartment;
import com.hospital.entity.ResponsibleHospital;
import com.hospital.service.FollowUpGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 随访组管理 service层
 */
@Service
@Transactional
public class FollowUpGroupServiceImpl implements FollowUpGroupService {
    /**
     * 注入 followUpGroup dao层对象
     */
    @Autowired
    private FollowUpGroupMapper followUpGroupMapper;

    /**
     * 添加随访组方法
     *
     * @param followUpGroup 随访组对象
     */
    @Override
    public Integer Insert(FollowUpGroup followUpGroup) {
        Integer state = followUpGroupMapper.Insert(followUpGroup);
        return state;
    }

    /**
     * 根据FollowUpGroup 主键查询
     *
     * @param id FollowUpGroup primary key
     * @return FollowUpGroup实体类对象
     */
    @Override
    public FollowUpGroup SelectByFollowUpGroupId(Integer id) {
        FollowUpGroup followUpGroup = followUpGroupMapper.SelectByFollowUpGroupId(id);
        return followUpGroup;
    }

    /**
     * 查询所有随访组
     *
     * @return 集合中的FollowUpGroup实体类对象
     */
    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    @Override
    public List<FollowUpGroup> selectAll(Integer page, Integer pageNum) {
        List<FollowUpGroup> followUpGroups = followUpGroupMapper.SelectAll(page, pageNum);
        return followUpGroups;
    }

    /**
     * 分页模糊查询
     *
     * @param followUpGroup FollowUpGroup实体类对象
     * @param page          当前页数
     * @param pageNum       每页显示页数
     * @return 集合中的FollowUpGroup实体类对象
     */
    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    @Override
    public List<FollowUpGroup> SelectLikeCondition( FollowUpGroup followUpGroup,Integer page, Integer pageNum) {
        List<FollowUpGroup> followUpGroups = followUpGroupMapper.SelectLikeCondition(followUpGroup,page, pageNum);
        return followUpGroups;
    }

    @Override
    public Integer SelectLikeConditionCount(FollowUpGroup followUpGroup) {
        Integer count = followUpGroupMapper.SelectLikeConditionCount(followUpGroup);
        return count;
    }

    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    @Override
    public Integer selectAllCount() {
        Integer count = followUpGroupMapper.SelectAllCount();
        return count;
    }

    /**
     * 查询责任医院
     *
     * @return 集合中ResponsibleHospital 实体类对象
     */
    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    @Override
    public List<ResponsibleHospital> SelectByResponsibleHospital() {
        List<ResponsibleHospital> responsibleHospitals = followUpGroupMapper.SelectByResponsibleHospital();
        return responsibleHospitals;
    }

    /**
     * 查询责任科室
     *
     * @return 集合中ResponsibleDepartment 实体类对象
     */
    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    @Override
    public List<ResponsibleDepartment> SelectByResponsibleDepartment() {
        List<ResponsibleDepartment> responsibleDepartments = followUpGroupMapper.SelectByResponsibleDepartment();
        return responsibleDepartments;
    }

    /**
     * 查询所有级别
     *
     * @return 集合中的Level实体类对象
     */
    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    @Override
    public List<Level> SelectByLevel() {
        List<Level> levels = followUpGroupMapper.SelectByLevel();
        return levels;
    }

    /**
     * 批量删除方法
     *
     * @param id 批量删除id
     * @return 删除状态
     */
    @Override
    public int bulkDelete(List<Integer> id) {
        int state = followUpGroupMapper.BulkDelete(id);
        return state;
    }

    @Override
    public Integer Update(FollowUpGroup followUpGroup) {
        Integer state = followUpGroupMapper.Update(followUpGroup);
        return state;
    }
}
